import Vue from 'vue'
import App from './App'
import store from 'store/index.js'

Vue.config.productionTip = false

App.mpType = 'app'

//创建过滤器
Vue.filter('formatCount', function(value) {
	if (value >= 10000 && value < 100000000) {
		value /= 10000
		return value.toFixed(1) + '万'
	} else if (value >= 100000000) {
		value /= 100000000
		return value.toFixed(1) + '亿'
	} else {
		return value
	}
})

//时间戳转换
Vue.filter('formatTime', function(value) {
	var date = new Date(value)
	var YY = date.getFullYear() + '-'
	var MM =
		(date.getMonth() + 1 < 10 ?
			'0' + (date.getMonth() + 1) :
			date.getMonth() + 1) + '-'
	var DD = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
	var hh =
		(date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
	var mm =
		(date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) +
		':'
	var ss =
		date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
	var newDate=new Date()
	if(newDate-date<=86400000) {
		return '今天' + ' ' + hh + mm + ss
	}else {
		return YY + MM + DD 
	}
	
})

const app = new Vue({
	...App,
	store
})
app.$mount()
